/*
 * Poyke Framework
 * Copyright (C) 2010 Poyke <http://code.google.com/p/poyke/>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef POYKE_STDAFX_H
#define POYKE_STDAFX_H

#include <stdlib.h>
#include <stdio.h>
#include <iostream>

// Required to make DLLs on Windows
#ifdef WIN32
#	 ifdef I_AM_A_CORE
#		 define POYKE_EXPORT __declspec(dllimport)
#		 define POYKE_IMPORT __declspec(dllexport)
#	 else
#		 define POYKE_EXPORT __declspec(dllexport)
#		 define POYKE_IMPORT __declspec(dllimport)
#	 endif
#else
#	 define POYKE_IMPORT
#	 define POYKE_EXPORT
#endif


#ifdef WIN32
#	define POYKE_INLINE __forceinline
#else
#	define POYKE_INLINE inline
#endif

#ifdef WIN32
#	include <windows.h>
#	define vsnprintf _vsnprintf_s
#endif

// Neutral type definitions
#ifdef WIN32
typedef signed __int64 int64;
typedef signed __int32 int32;
typedef signed __int16 int16;
typedef signed __int8 int8;

typedef unsigned __int64 uint64;
typedef unsigned __int32 uint32;
typedef unsigned __int16 uint16;
typedef unsigned __int8 uint8;
#else
#include <stdint.h>
typedef int64_t int64;
typedef int32_t int32;
typedef int16_t int16;
typedef int8_t int8;

typedef uint64_t uint64;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
#endif


// General library loading macros
#ifdef WIN32
	typedef HINSTANCE CORE;
#	define POYKE_LOAD_MODULE(m) (LoadLibrary(m".dll"))
#	define POYKE_DEL_MODULE(m)  (FreeLibrary(m))
#	define POYKE_GET_SYMBOL(m,s) (GetProcAddr(m,s))
#else
#	include <dlfcn.h>
	typedef void* CORE;
#	define POYKE_LOAD_MODULE(m) (dlopen("lib"m".so",RTLD_NOW))
	// dlclose returns 0 on success, so this hack is requried to keep the code simple and cross-platform
#	define POYKE_DEL_MODULE(m) (!dlclose(m))
#	define POYKE_GET_SYMBOL(m,s) (dlsym(m,s))
#endif

#include "CoreLoader.h"
#include "LogMgr.h"
#include "ThreadMgr.h"

#endif
